package main

import "fmt"

func xx(name string) {
	fmt.Println("hello", name)
}

// 函数作为参数
func xy(f func(string), name string) {
	f(name)
}

// 函数作为返回值
func ab() func(int, int) int {
	return func(x, y int) int {
		return x + y
	}
}

func low(f func()) {
	f()
}

// 闭包
func bi(f func(string), name string) func() {
	return func() {
		f(name)
	}
}

func main() {
	xy(xx, "a")
	ret := ab()
	fmt.Printf("%T\n", ret)
	c := ret(1, 2)
	fmt.Println(c)
	ff := bi(xx, "tansi")
	low(ff)
}
